package main;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Toolkit;

import javax.swing.JApplet;

import parser.graph.SmartParserRunnable;
import smarties.info.panel.SmartInfoPanel;

import com.touchgraph.graphlayout.GLPanel;
import com.touchgraph.graphlayout.Node;

public class SmartApplet extends JApplet
{
	/**
	 * 
	 */
	private static final long	serialVersionUID	= -982798754720311902L;

	@SuppressWarnings("unchecked")
	private GLPanel				panel;

	@SuppressWarnings("unchecked")
	@Override
	public void init()
	{
		// TODO : mettre ca dans le xml
		Node.setNodeBackFixedColor(new Color(0.9f, 0.8f, 0.95f));
		Node.setNodeBackSelectColor(new Color(0.9f, 0.8f, 0.95f));
		Node.setNodeBorderMouseOverColor(new Color(0.9f, 0.8f, 0.95f, 0.5f));
		Node.setNodeMarkForRemovalColor(new Color(1f, 1f, 1f, 0));
		Node.setNodeJustMadeLocalColor(new Color(1f, 0, 0, 0.1f));

		this.getContentPane().setLayout(new BorderLayout());
		int width = 800;
		int height = 600;
		this.setSize(width, height);

		this.panel = new GLPanel();
		this.panel.setSize(width, height);
		this.panel.setPreferredSize(this.getSize());
		this.panel.initialize();

		this.getContentPane().add(this.panel, BorderLayout.CENTER);

		Toolkit.getDefaultToolkit().setDynamicLayout(true);

		SmartInfoPanel smartInfoPanel = new SmartInfoPanel(this.panel);
		this.getContentPane().add(smartInfoPanel, BorderLayout.WEST);

		SmartParserRunnable parserRunnable = new SmartParserRunnable(
				"../ressource/Smart iTunes Music Library.xml", this.panel, this);
		Thread thread = new Thread(parserRunnable);
		thread.start();
	}
}
